home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_pow_carbgun_m.cog < prev    next >
Text File  |  1998-02-25  |  4KB  |  137 lines

  1. # Jedi Knight Mission Cog Script
  2. #
  3. # POW_CARBGUN_M.COG
  4. #
  5. # POWERUP Script - Carbonite Gun pickup
  6. #
  7. # [YB & CYW] + [RF]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. thing       powerup                          local
  15. thing       player                           local
  16. int         bin=20                           local
  17. int         ammobin=90                       local
  18. sound       pickupsnd=thrmlpu2.wav           local
  19. sound       respawnsnd=Activate01.wav        local
  20. flex        amount                           local
  21.  
  22. int         bin_contents=0                   local
  23. int         autopickup=0                     local
  24. int         autoselect_weapon=-1             local
  25.  
  26. message     touched
  27. message     taken
  28. message     respawn
  29.  
  30. end
  31.  
  32. # ========================================================================================
  33.  
  34. code
  35.  
  36. touched:
  37.    player = GetSourceRef();
  38.  
  39.    if (GetThingType(player) == 10)  // Can only be taken by players.
  40.    {
  41.       if(IsMulti() || (GetInv(player, GetWeaponBin(bin)) == 0) || (GetInv(player, ammobin) < GetInvMax(player, ammobin)))
  42.       {
  43.          TakeItem(GetSenderRef(), -1);
  44.          call taken;
  45.       }
  46.    }
  47.    Return;
  48.  
  49. # ........................................................................................
  50.  
  51. taken:
  52.    player = GetSourceRef();
  53.    powerup = GetSenderRef();
  54.  
  55.    // Do effects.
  56.    PlaySoundLocal(pickupsnd, 1, 0, 0);
  57.    AddDynamicTint(player, 0.0, 0.0, 0.2);
  58.  
  59.    if(GetInv(player, GetWeaponBin(bin)) == 0)
  60.    {
  61.       // Pickup gun and ammo.
  62.       jkPrintUNIString(player, GetWeaponBin(bin));
  63.  
  64.       ChangeInv(player, GetWeaponBin(bin), 1.0);
  65.  
  66.       // store the old bin contents
  67.       bin_contents = GetInv(player, ammobin);
  68.       ChangeInv(player, ammobin, 5.0);
  69.  
  70.       // Check for Auto Pickup
  71.       autopickup = GetAutoPickup();
  72.       if(autopickup & 1)
  73.       {
  74.          if(!((autopickup & 4) && (GetWeaponPriority(player, GetWeaponBin(GetCurWeapon(player))) >= GetWeaponPriority(player, GetWeaponBin(bin)))))
  75.          {
  76.             if(!((autopickup & 8) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  77.             {
  78.                SelectWeapon(player, GetWeaponBin(bin));
  79.                Return;
  80.             }
  81.          }
  82.       }
  83.  
  84.       // Check for Auto Reload
  85.       if(GetAutoReload() & 1)
  86.       {
  87.          if(!bin_contents)
  88.          {
  89.             if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  90.             {
  91.                // Try to autoselect and see if the best weapon is the carbo gun
  92.                autoselect_weapon = AutoSelectWeapon(player, 2);
  93.                if (autoselect_weapon == bin)
  94.                   SelectWeapon(player, GetWeaponBin(bin));
  95.             }
  96.          }
  97.       }
  98.    }
  99.    else
  100.    if(GetInv(player, ammobin) < GetInvMax(player, ammobin))
  101.    {
  102.       // Pickup ammo only.
  103.       // Print("Energy Cells");
  104.       jkPrintUNIString(player, ammobin);
  105.  
  106.       // store the old bin contents
  107.       bin_contents = GetInv(player, ammobin);
  108.  
  109.       ChangeInv(player, ammobin, 5.0);
  110.  
  111.       // Check for Auto Reload
  112.       if(GetAutoReload() & 1)
  113.       {
  114.          if(!bin_contents)
  115.          {
  116.             if(!((GetAutoReload() & 2) && (GetWeaponBin(GetCurWeapon(player)) == jkGetMultiParam(1))))
  117.             {
  118.             // Try to autoselect and see if the best weapon is an carbonite weapon
  119.             autoselect_weapon = AutoSelectWeapon(player, 2);
  120.             if (autoselect_weapon == bin)
  121.                SelectWeapon(player, GetWeaponBin(bin));
  122.             }
  123.          }
  124.       }
  125.    }
  126.  
  127.    Return;
  128.  
  129. # ........................................................................................
  130.  
  131. respawn:
  132.    PlaySoundThingLocal(respawnsnd, GetSenderRef(), 0.6, 5.0, 10.0, 0);
  133.  
  134.    Return;
  135.  
  136. end
  137.